package cn.rkylin.oms.order.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.rkylin.core.service.ApolloService;
import cn.rkylin.oms.order.dao.INoteDAO;
import cn.rkylin.oms.order.vo.NoteVO;

/**
 * OrderNotes服务层实现
 * @author wangxiaoyi
 * @version 1.0
 * @created 14-9月-2017 16:04:53
 */
@Service("noteService")
public class NoteServiceImpl extends ApolloService implements INoteService {

    @Autowired
    private INoteDAO noteDAO;
    
	public NoteServiceImpl(){

	}

	public void finalize() throws Throwable {

	}

	/**
	 * 查询使签，不分页
	 * 
	 * @param OrderNotes
	 */
	public List<NoteVO> getNotes(NoteVO noteVO)throws Exception{
		return noteDAO.getNotes(noteVO);
	}

    @Override
    public Map<String, Object> createNote(NoteVO noteVO) throws Exception {
        Map<String, Object> returnMap = new HashMap<String, Object>();    
        noteVO.setNoteId(java.util.UUID.randomUUID().toString().replaceAll("-", ""));
        noteDAO.insert(noteVO);
        returnMap.put("isOk", "y");
        returnMap.put("errorMessage", "");
        return returnMap;
    }

    @Override
    public Map<String, Object> updateNote(NoteVO noteVO) throws Exception {
        Map<String, Object> returnMap = new HashMap<String, Object>();
        noteDAO.update(noteVO);
        returnMap.put("isOk", "y");
        returnMap.put("errorMessage", "");
        return returnMap;
    }

    /**
     * 根据业务主键获取内部便签列表.
     * @throws Exception 
     * @see cn.rkylin.oms.order.service.INoteService#getNotesByBusiKey(java.lang.String)
     */
    @Override
    public List<NoteVO> getNotesByBusiKey(String busiKey) throws Exception {
        NoteVO noteVO = new NoteVO();
        noteVO.setSourCodeId(busiKey);
        return noteDAO.getNotes(noteVO);
    }

}